package com.example.beautymakeup.dao;

import com.example.beautymakeup.pojo.Hot;
import com.example.beautymakeup.pojo.Order;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderDao {
    @Select("select o.*,s.shopName,s.shopImage from `order` o,shop s where o.shopId = s.uid and o.userId = #{userId} order by date DESC;")
    List<Order> getByUserId(int userId);

    @Select("select o.*,s.shopName,s.shopImage from `order` o,shop s where o.shopId = s.uid order by `date` DESC limit #{page},#{size};")
    List<Order> getAll(@Param("page") int page, @Param("size") int size);

    @Select("select o.*,s.shopName,s.shopImage from `order` o,shop s where o.shopId = s.uid and o.`status` = #{status} order by `date` DESC limit #{page},#{size};")
    List<Order> getByStatus(@Param("status") int status,@Param("page") int page, @Param("size") int size);

    @Select("select o.*,s.shopName,s.shopImage from `order` o,shop s where o.shopId = s.uid and o.uid = #{uid};")
    Order getByUid(int uid);

    @Select("select count(*) from `order`;")
    int getAllCount();

    @Select("select count(*) from `order` where status = #{status};")
    int getByStatusCount(int status);

    @Insert("insert into `order` (userId,count,price,shopId,addressName,phone,address,date) values (#{userId},#{count},#{price},#{shopId},#{addressName},#{phone},#{address},#{date});")
    int insert(Order order);

    @Update("update `order` set status = #{status} where uid = #{uid};")
    int update(Order order);

    @Update("update `order` set status = 6 where uid = #{uid};")
    int refund(Order order);


}
